using System.Collections;
using Holoville.HOTween;
using UnityEngine;

public class ScrollOnStartPosition : MonoBehaviour
{
	public bool RepositionOnEnable;

	public UIScrollView scrollView;

	public EaseType ease;

	[Range(0f, 1f)]
	public float x = 1f;

	private void Awake()
	{
		if (scrollView == null)
		{
			scrollView = base.gameObject.GetComponent<UIScrollView>();
		}
	}

	private void OnEnable()
	{
		ResetPossition();
	}

	private void OnDisable()
	{
		ResetPossition();
	}

	public void SetDrag()
	{
		scrollView.SetDragAmount(x, 0f, false);
	}

	public void Reset()
	{
		scrollView.ResetPosition();
	}

	private void ResetPossition()
	{
		if (RepositionOnEnable && scrollView != null)
		{
			scrollView.ResetPosition();
		}
	}

	private IEnumerator WaitForRealSecond(float time)
	{
		float start = Time.realtimeSinceStartup;
		while (Time.realtimeSinceStartup < start + time)
		{
			yield return null;
		}
	}
}
